]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Support xulrunner 1.9.3+
authorColin Walters <walters@verbum.org>
Fri, 24 Sep 2010 18:02:04 +0000 (14:02 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Thu, 30 Sep 2010 16:43:12 +0000 (12:43 -0400)
Add small wrappers around JS_AddValueRoot.
Add JS_BeginRequest in our custom code.

https://bugzilla.gnome.org/show_bug.cgi?id=630539

configure.ac
src/Makefile.am
src/shell-global.c
src/shell-jsapi-compat-private.h [new file with mode: 0644]

index 0b480324ea2a1df5f74277ea91d84f4735c2ecdd..b1e0eabfa8a60789ff52a0450333a28117f29a90 100644 (file)
@@ -77,13 +77,12 @@ PKG_CHECK_MODULES(MUTTER_PLUGIN, gio-2.0 >= $GIO_MIN_VERSION
                                  libstartup-notification-1.0
                                  gobject-introspection-1.0 >= $GOBJECT_INTROSPECTION_MIN_VERSION)
 
-# This is for the newly added application id bits, we can replace this with
-# a version check later
 saved_CFLAGS=$CFLAGS
 saved_LIBS=$LIBS
 CFLAGS=$MUTTER_PLUGIN_CFLAGS
 LIBS=$MUTTER_PLUGIN_LIBS
-AC_CHECK_FUNCS(sn_startup_sequence_get_application_id)
+# sn_startup_sequence_get_application_id, we can replace with a version check later
+AC_CHECK_FUNCS(JS_NewGlobalObject sn_startup_sequence_get_application_id)
 CFLAGS=$saved_CFLAGS
 LIBS=$saved_LIBS
 
index db97ef2e6b1219c7dd9b54824d6e9a550f5cec54..094f2d4fbd6ac36ebe99746bab06ca3731e4ce28 100644 (file)
@@ -87,6 +87,7 @@ libgnome_shell_la_SOURCES =           \
        shell-app-private.h             \
        shell-embedded-window-private.h \
        shell-global-private.h          \
+       shell-jsapi-compat-private.h    \
        shell-window-tracker-private.h  \
        shell-wm-private.h      \
        gnome-shell-plugin.c            \
index 59e4dbbf9633b6e9fdcc7a3b98aa014e24e78759..5251380d109d848aa84f9b660a175e2a0c10e979 100644 (file)
@@ -27,6 +27,7 @@
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
+#include "shell-jsapi-compat-private.h"
 
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
@@ -810,6 +811,8 @@ shell_global_add_extension_importer (ShellGlobal *global,
   JSContext *context = gjs_context_get_native_context (global->js_context);
   char *search_path[2] = { 0, 0 };
 
+  JS_BeginRequest (context);
+
   // This is a bit of a hack; ideally we'd be able to pass our target
   // object directly into this function, but introspection doesn't
   // support that at the moment.  Instead evaluate a string to get it.
@@ -829,18 +832,22 @@ shell_global_add_extension_importer (ShellGlobal *global,
                   G_IO_ERROR_FAILED,
                   "%s", message ? message : "(unknown)");
       g_free(message);
-      return FALSE;
+      goto out_error;
     }
 
   if (!JSVAL_IS_OBJECT (target_object))
     {
       g_error ("shell_global_add_extension_importer: invalid target object");
-      return FALSE;
+      goto out_error;
     }
 
   search_path[0] = (char*)directory;
   importer = gjs_define_importer (context, JSVAL_TO_OBJECT (target_object), target_property, (const char **)search_path, FALSE);
+  JS_EndRequest (context);
   return TRUE;
+ out_error:
+  JS_EndRequest (context);
+  return FALSE;
 }
 
 /* Code to close all file descriptors before we exec; copied from gspawn.c in GLib.
@@ -1604,7 +1611,8 @@ shell_global_set_property_mutable (ShellGlobal *global,
   jsuint attrs;
   JSBool found;
 
-  JS_AddRoot (context, &val);
+  JS_BeginRequest (context);
+  JS_AddValueRoot (context, &val);
 
   parts = g_strsplit (object, ".", -1);
   obj = JS_GetGlobalObject (context);
@@ -1613,30 +1621,31 @@ shell_global_set_property_mutable (ShellGlobal *global,
       if (!JS_GetProperty (context, obj, parts[i], &val))
         {
           g_strfreev (parts);
-          JS_RemoveRoot (context, &val);
-          gjs_log_exception (context, NULL);
-          return FALSE;
+          goto out_error;
         }
       obj = JSVAL_TO_OBJECT (val);
     }
   g_strfreev (parts);
 
   if (!JS_GetPropertyAttributes (context, obj, property, &attrs, &found) || !found)
-    {
-      JS_RemoveRoot (context, &val);
-      gjs_log_exception (context, NULL);
-      return FALSE;
-    }
+    goto out_error;
 
   if (mutable)
     attrs &= ~(JSPROP_PERMANENT | JSPROP_READONLY);
   else
     attrs |= (JSPROP_PERMANENT | JSPROP_READONLY);
 
-  JS_SetPropertyAttributes (context, obj, property, attrs, &found);
+  if (!JS_SetPropertyAttributes (context, obj, property, attrs, &found))
+    goto out_error;
 
-  JS_RemoveRoot (context, &val);
-  return !gjs_log_exception (context, NULL);
+  JS_RemoveValueRoot (context, &val);
+  JS_EndRequest (context);
+  return TRUE;
+ out_error:
+  gjs_log_exception (context, NULL);
+  JS_RemoveValueRoot (context, &val);
+  JS_EndRequest (context);
+  return FALSE;
 }
 
 typedef struct
diff --git a/src/shell-jsapi-compat-private.h b/src/shell-jsapi-compat-private.h
new file mode 100644 (file)
index 0000000..7f0304b
--- /dev/null
@@ -0,0 +1,44 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * shell-jsapi-compat.h: Compatibility wrapper for older Spidermonkey
+ *
+ * Copyright 2010 Red Hat, Inc.
+*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __SHELL_JSAPI_COMPAT_H__
+#define __SHELL_JSAPI_COMPAT_H__
+
+#include "config.h"
+
+#ifndef HAVE_JS_NEWGLOBALOBJECT
+
+/* The old JS_AddRoot accepted anything via void *, new
+ * api is stricter.
+ */
+#define JS_AddValueRoot JS_AddRoot
+#define JS_AddObjectRoot JS_AddRoot
+#define JS_AddStringRoot JS_AddRoot
+#define JS_AddGCThingRoot JS_AddRoot
+#define JS_RemoveValueRoot JS_RemoveRoot
+#define JS_RemoveObjectRoot JS_RemoveRoot
+#define JS_RemoveStringRoot JS_RemoveRoot
+#define JS_RemoveGCThingRoot JS_RemoveRoot
+
+#endif
+
+#endif